<template>
  <div class="p-2">
    <el-row :gutter="20">
      <el-col :lg="24" :xs="24">
        <div v-show="showSearch" class="mb-[10px]">
          <el-card shadow="hover">
            <el-form ref="queryFormRef" :model="queryParams" :inline="true">
              <el-form-item label="用户名称" prop="userName">
                <el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
                <el-button icon="Refresh" @click="resetQuery">重置</el-button>
              </el-form-item>
            </el-form>
          </el-card>
        </div>

        <el-card shadow="hover">
          <template #header>
            <el-row :gutter="10">
              <el-col :span="1.5">
<!--                <el-button type="primary" plain icon="Plus" @click="handleAdd()">新增</el-button>-->
                <el-tag>操作栏</el-tag>
              </el-col>
              <right-toolbar v-model:show-search="showSearch" :columns="columns" :search="true" @query-table="getList"></right-toolbar>
            </el-row>
          </template>

          <el-table v-loading="loading" border :data="listData" @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="50" align="center" />
            <template v-for="(item, index) in columns">
              <el-table-column v-if="item.visible"
                               :key="item.key"
                               :label="item.label"
                               align="center"
                               :width="item.width"
                               :prop="item.key" >
                <template v-slot="scope">
                  <template v-if="item.label === '审批状态'">
                    <el-tag type="warning" v-if="scope.row.审批状态 === '待提交'">{{ scope.row.审批状态 }}</el-tag>
                    <el-tag type="success" v-if="scope.row.审批状态 === '审核通过'">{{ scope.row.审批状态 }}</el-tag>
                    <el-tag type="danger" v-if="scope.row.审批状态 === '审核驳回'">{{ scope.row.审批状态 }}</el-tag>
                    <el-tag v-if="scope.row.审批状态 === '审核中'">{{ scope.row.审批状态 }}</el-tag>
                  </template>
                </template>
              </el-table-column>
            </template>

            <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
              <template #default="scope">
                <el-button type="success" size="small">通过</el-button>
                <el-button type="danger" size="small">驳回</el-button>
              </template>
            </el-table-column>
          </el-table>

          <pagination
            v-show="total > 0"
            v-model:page="queryParams.pageNum"
            v-model:limit="queryParams.pageSize"
            :total="total"
            @pagination="getList"
          />
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup>
// 方法
import { ref } from 'vue'
// 列显隐信息
const columns = ref([
  { key: '采样标签', label: `采样标签`, visible: true, width: "200", children: [] },
  { key: '审批状态', label: `审批状态`, visible: true, width: "", children: [] },
  { key: '审批序号', label: `审批序号`, visible: true, width: "", children: [] },
  { key: '创建人', label: `创建人`, visible: true, width: "", children: [] },
  { key: '创建时间', label: `创建时间`, visible: true, width: "", children: [] },
  { key: '原检测员', label: `原检测员`, visible: true, width: "", children: [] },
  { key: '新检测员', label: `新检测员`, visible: true, width: "", children: [] },
]);

const queryParams = ref({
  pageNum: 1,
  pageSize: 10,
})
const total = ref(0)
const showSearch = ref(true);
const loading = ref(true);
const listData = ref([
  {
    "采样标签": "CAIYANG202506190010",
    "审批状态": "待提交",
    "审批序号": "SP-202507001",
    "创建人": "张明",
    "创建日期": "2025-07-01",
    "创建时间": "09:15:30",
    "关联": "设备检测-001",
    "原检测员": "李华",
    "新检测员": "王强"
  },
  {
    "采样标签": "CAIYANG202506190009",
    "审批状态": "审核通过",
    "审批序号": "SP-202507002",
    "创建人": "刘芳",
    "创建日期": "2025-07-02",
    "创建时间": "14:20:15",
    "关联": "环境检测-003",
    "原检测员": "赵刚",
    "新检测员": "陈璐"
  },
  {
    "采样标签": "CAIYANG202506190008",
    "审批状态": "审核驳回",
    "审批序号": "SP-202507003",
    "创建人": "王磊",
    "创建日期": "2025-07-03",
    "创建时间": "10:05:45",
    "关联": "原料检测-002",
    "原检测员": "孙婷",
    "新检测员": "周明"
  },
  {
    "采样标签": "CAIYANG202506190007",
    "审批状态": "待提交",
    "审批序号": "SP-202507004",
    "创建人": "陈燕",
    "创建日期": "2025-07-04",
    "创建时间": "16:30:20",
    "关联": "成品检测-005",
    "原检测员": "吴伟",
    "新检测员": "郑华"
  },
  {
    "采样标签": "CAIYANG202506190006",
    "审批状态": "审核中",
    "审批序号": "SP-202507005",
    "创建人": "周伟",
    "创建日期": "2025-07-05",
    "创建时间": "08:45:10",
    "关联": "包装检测-004",
    "原检测员": "徐娜",
    "新检测员": "林芳"
  },
  {
    "采样标签": "CAIYANG202506190005",
    "审批状态": "审核通过",
    "审批序号": "SP-202507006",
    "创建人": "郑敏",
    "创建日期": "2025-07-06",
    "创建时间": "11:20:35",
    "关联": "设备检测-007",
    "原检测员": "郭杰",
    "新检测员": "胡勇"
  },
  {
    "采样标签": "CAIYANG202506190004",
    "审批状态": "待提交",
    "审批序号": "SP-202507007",
    "创建人": "胡军",
    "创建日期": "2025-07-07",
    "创建时间": "15:10:50",
    "关联": "环境检测-006",
    "原检测员": "黄芳",
    "新检测员": "袁明"
  },
  {
    "采样标签": "CAIYANG202506190003",
    "审批状态": "审核驳回",
    "审批序号": "SP-202507008",
    "创建人": "林芳",
    "创建日期": "2025-07-08",
    "创建时间": "09:30:15",
    "关联": "原料检测-009",
    "原检测员": "罗明",
    "新检测员": "邓婷"
  },
  {
    "采样标签": "CAIYANG202506190002",
    "审批状态": "审核通过",
    "审批序号": "SP-202507009",
    "创建人": "邓婷",
    "创建日期": "2025-07-09",
    "创建时间": "13:45:20",
    "关联": "成品检测-008",
    "原检测员": "夏伟",
    "新检测员": "卢芳"
  },
  {
    "采样标签": "CAIYANG202506190001",
    "审批状态": "审核中",
    "审批序号": "SP-202507010",
    "创建人": "袁明",
    "创建日期": "2025-07-01",
    "创建时间": "17:20:40",
    "关联": "包装检测-010",
    "原检测员": "钟华",
    "新检测员": "汪伟"
  }
]);


// 获取数据
const getList = () => {
  loading.value = false
}

// 搜索
const handleQuery = () => {
}

// 重置
const resetQuery = () => {
  for (let i in queryParams.value) {
    if (i !== 'pageNum' && i !== 'pageSize') {
      queryParams.value[i] = undefined
    }
  }
  handleQuery()
}

// 多选
const handleSelectionChange = () => {
}

// 新增
const handleAdd = () => {
}


getList()
</script>
